﻿namespace Caltrain.Model
{
    using System;
    using System.Collections.Generic;
    using ProtoBuf;

    [ProtoContract()]
    public class Schedule
    {
        [ProtoMember(1)]
        public Dictionary<string, Stop> StopsById;

        [ProtoMember(2)]
        public Dictionary<int, List<StopTime>> StopTimesByStopId;

        [ProtoMember(3)]
        public Dictionary<int, Trip> TripsByLookupId;

        [ProtoMember(4)]
        public Calendar Calendar;
    }

    [ProtoContract()]
    public class StopTime
    {
        [ProtoMember(1)]
        public int TripLookupId;

        [ProtoMember(2)]
        public TimeSpan ArrivalTime;

        [ProtoMember(3)]
        public TimeSpan DepartureTime;

        [ProtoMember(4)]
        public int StopLookupId;

        [ProtoMember(5)]
        public int Sequence;

        [ProtoMember(6)]
        public string TrainId;
    }

    [ProtoContract()]
    public class Stop
    {
        [ProtoMember(1)]
        public int LookupId;

        [ProtoMember(2)]
        public string Id;

        [ProtoMember(3)]
        public double Latitude;

        [ProtoMember(4)]
        public double Longitude;

        [ProtoMember(5)]
        public int ZoneId;
    }

    [ProtoContract()]
    public class Trip
    {
        [ProtoMember(1)]
        public int LookupId;

        [ProtoMember(2)]
        public string Id;

        [ProtoMember(3)]
        public string RouteId;

        [ProtoMember(4)]
        public string ServiceId;
    }

    [ProtoContract()]
    public class Service
    {
        [ProtoMember(1)]
        public string Id;

        [ProtoMember(2)]
        public Dictionary<DayOfWeek, bool> Days;

        [ProtoMember(3)]
        public DateTime StartDate;

        [ProtoMember(4)]
        public DateTime EndDate;
    }

    [ProtoContract()]
    public class ServiceException
    {
        [ProtoMember(1)]
        public string ServiceId;

        [ProtoMember(2)]
        public bool AddedOrRemoved;
    }

    [ProtoContract()]
    public class Calendar
    {
        [ProtoMember(1)]
        public Service[] Services;

        [ProtoMember(2)]
        public Dictionary<DateTime, ServiceException> Exceptions;
    }
}
